package online.hxstart.code.concurrent.chapter01;

/**
 * @author huxing
 * @date 19-4-22 星期一 下午4:04
 * @describe 多线程打印
 */
public class TicketWindow extends Thread {

  private String name;

  private static final int MAX = 50;

  private int index;

  private TicketWindow(String name) {
    this.name = name;
  }

  @Override
  public void run() {
    while (index <= MAX) {
      System.out.println("柜台：" + name + "当前号码是：" + (index));
      index++;
    }
  }

  public static void main(String[] args) {
    TicketWindow ticketWindow1 = new TicketWindow("一号出号机");
    ticketWindow1.start();
    TicketWindow ticketWindow2 = new TicketWindow("二号出号机");
    ticketWindow2.start();
    TicketWindow ticketWindow3 = new TicketWindow("三号出号机");
    ticketWindow3.start();
    TicketWindow ticketWindow4 = new TicketWindow("四号出号机");
    ticketWindow4.start();
  }
}
